/*
 * Copyright (c) 2011, Brookhaven National Laboratory
 * All rights reserved.
 * The software in this package is published under the terms
 * of the BSD license a copy of which has been included with
 * this distribution in the license.txt file.
 */

#include <dds/core/Exception.hpp>
#include <dds/xtypes/TypeObject.hpp>

#include <tdds/xtypes/DynamicType.hpp>
#include "dds/type/dynamic/detail/DynamicType.h"
#include "oxtypes/delegate/DynamicType.h"

#include "dds/type/dynamic/detail/Descriptor.h"

typedef dds::type::dynamic::detail::DynamicType DT;

namespace dds { namespace type { namespace dynamic { namespace detail {

  DynamicType::DynamicType() :
    dds::core::Reference<oxtypes::delegate::DynamicType> () {
  }

  DynamicType::DynamicType(oxtypes::delegate::DynamicType* ptr) :
    dds::core::Reference<oxtypes::delegate::DynamicType> (ptr) {
  }

  DynamicType::~DynamicType() {
  }

}}}}


namespace tdds { namespace type { namespace dynamic {

template <> const dds::type::dynamic::TypeDescriptor 
DynamicType<DT>::descriptor() const {
  return d_->td;
}
    
template <> void 
DynamicType<DT>::descriptor(const dds::type::dynamic::TypeDescriptor& value){
   throw dds::core::UnsupportedError("");
}

template <> const std::string 
DynamicType<DT>::name() const {
  return d_->td.name();
}

template <> dds::type::TypeKind 
DynamicType<DT>::kind() const {
  return d_->td.kind();
}

template <> dds::type::dynamic::DynamicTypeMember
DynamicType<DT>::member(const std::string& name) const {
  throw dds::core::UnsupportedError("");
}

template <> const dds::type::dynamic::DynamicTypeMembersByName
DynamicType<DT>::all_members_by_name() const {
  return *(d_->members);
}

template <> dds::type::dynamic::DynamicTypeMembersByName&
DynamicType<DT>::all_members_by_name(
   dds::type::dynamic::DynamicTypeMembersByName& dst) {
  throw dds::core::UnsupportedError("");
}
    
template <> dds::type::dynamic::DynamicTypeMember
DynamicType<DT>::member(dds::type::MemberId id) {
  throw dds::core::UnsupportedError("");
}

template <> const dds::type::dynamic::DynamicTypeMembersById
DynamicType<DT>::all_members_by_id() const {
 return *(d_->memberByIds); 
}

template <> dds::type::dynamic::DynamicTypeMembersById&
DynamicType<DT>::all_members_by_id(
  dds::type::dynamic::DynamicTypeMembersById& value) const {
  throw dds::core::UnsupportedError("");
}

template <> const dds::type::dynamic::AnnotationDescriptorSeq 
DynamicType<DT>::annotation() const {
  throw dds::core::UnsupportedError("");
}
    
template <> dds::type::dynamic::AnnotationDescriptorSeq&
DynamicType<DT>::annotation(dds::type::dynamic::AnnotationDescriptorSeq& dst) const {
  throw dds::core::UnsupportedError("");
}
    
template <> void 
DynamicType<DT>::apply_annotation(
  const dds::type::dynamic::AnnotationDescriptor& descriptor) {
  throw dds::core::UnsupportedError("");
}

template <> DynamicType<DT>& 
DynamicType<DT>::operator+=(
 const dds::type::dynamic::AnnotationDescriptor& descriptor){
  this->apply_annotation(descriptor);
  return *this;
}

template <> dds::type::dynamic::DynamicTypeMember
DynamicType<DT>::add_member(const dds::type::dynamic::MemberDescriptor& descriptor) {
  throw dds::core::UnsupportedError("");
}

template <> DynamicType<DT>&
DynamicType<DT>::operator+=(const dds::type::dynamic::MemberDescriptor& descriptor){
  this->add_member(descriptor);
  return *this;
}


}}}
